﻿using System;
using System.Collections.Generic;
using System.ComponentModel;
using System.Data;
using System.Drawing;
using System.Linq;
using System.Text;
using System.Windows.Forms;
using Oracle.DataAccess.Client;

namespace TestOracle
{
    public partial class Form1 : Form
    {
        public Form1()
        {
            InitializeComponent();
        }

        private void button1_Click(object sender, EventArgs e)
        {
            string oradb = "Data Source=(DESCRIPTION="
             + "(ADDRESS=(PROTOCOL=TCP)(HOST=localhost)(PORT=1521))"
             + "(CONNECT_DATA=(SERVICE_NAME=ORCL)));"
             + "User Id=hr;Password=hr;";
            OracleConnection oc = new OracleConnection(oradb);
            oc.Open();
            string sql = " select department_name from departments where department_id = 10"; // C#
            OracleCommand cmd = new OracleCommand(sql, oc);
            cmd.CommandType = CommandType.Text;
            OracleDataReader dr=cmd.ExecuteReader();
            dr.Read();
            label1.Text = dr.GetString(0);
        }
    }
}
